package com.elitel.frame.base.controller;

import com.elitel.frame.base.service.SysPrjserviceCategoryService;
import com.elitel.frame.main.entity.SysPrjserviceCategory;
import com.elitel.frame.main.entity.vo.JsonResult;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * 数据服务分类(SysPrjserviceCategory)表控制层
 *
 * @author makejava
 * @since 2025-01-08 17:02:49
 */
@RestController
@RequestMapping("prjservicecategory")
public class SysPrjserviceCategoryController {
    /**
     * 服务对象
     */
    @Resource
    private SysPrjserviceCategoryService sysPrjserviceCategoryService;


    /**
     * 分页查询
     *
     * @param sysPrjserviceCategory 筛选条件
     * @return 查询结果
     */
    @GetMapping("getTree")
    public JsonResult getTree(SysPrjserviceCategory sysPrjserviceCategory) {
        JsonResult res = new JsonResult();
        try {
            List<SysPrjserviceCategory> list = sysPrjserviceCategoryService.getTree();
            res.setSuccess(true);
            res.setData(list);
            res.setMsg("查询成功");
        } catch (Exception e) {
            e.printStackTrace();
            res.setSuccess(false);
            res.setMsg("查询失败");
        }
        return res;
    }
    @GetMapping("getGroupTree")
    public JsonResult getTree() {
        JsonResult res = new JsonResult();
        try {
            Object groupTree = sysPrjserviceCategoryService.getGroupTree2();
            res.setSuccess(true);
            res.setData(groupTree);
            res.setMsg("查询成功");
        } catch (Exception e) {
            e.printStackTrace();
            res.setSuccess(false);
            res.setMsg("查询失败");
        }
        return res;
    }

    /**
     * 保存
     *
     * @param sysPrjserviceCategory
     * @return 查询结果
     */
    @PostMapping("saveNode")
    public JsonResult saveNode(@RequestBody SysPrjserviceCategory sysPrjserviceCategory) {
        JsonResult res = new JsonResult();
        try {
            sysPrjserviceCategoryService.saveNode(sysPrjserviceCategory);
            res.setSuccess(true);
            res.setMsg("查询成功");
        } catch (Exception e) {
            e.printStackTrace();
            res.setSuccess(false);
            res.setMsg(e.getMessage());
        }
        return res;
    }


    /**
     * 删除
     *
     * @param sysPrjserviceCategory 筛选条件
     * @return 查询结果
     */
    @PostMapping("delNode")
    public JsonResult delNode(@RequestBody SysPrjserviceCategory sysPrjserviceCategory) {
        JsonResult res = new JsonResult();
        try {
            sysPrjserviceCategoryService.delNode(sysPrjserviceCategory);
            res.setSuccess(true);
            res.setMsg("查询成功");
        } catch (Exception e) {
            e.printStackTrace();
            res.setSuccess(false);
            res.setMsg("查询失败");
        }
        return res;
    }


}

